package com.fr.report.script.core.parser;

import com.fr.base.ColumnRow;
import com.fr.base.core.antlr.LLkParser;
import com.fr.base.core.antlr.NoViableAltException;
import com.fr.base.core.antlr.ParserSharedInputState;
import com.fr.base.core.antlr.RecognitionException;
import com.fr.base.core.antlr.Token;
import com.fr.base.core.antlr.TokenBuffer;
import com.fr.base.core.antlr.TokenStream;
import com.fr.base.core.antlr.TokenStreamException;
import java.util.ArrayList;
import java.util.List;

public class FRParser extends LLkParser
  implements FRParserTokenTypes
{
  public static final String[] _tokenNames = { "<0>", "EOF", "<2>", "NULL_TREE_LOOKAHEAD", "DOT", "FLOT_NUM", "LOR", "LAND", "EQUAL", "EQUAL2", "NOT_EQUAL", "NOT_EQUAL2", "GE", "GT", "LE", "LT", "PLUS", "MINUS", "STAR", "DIV", "MOD", "POWER", "LNOT", "IDENT", "LPAREN", "COMMA", "RPAREN", "COLON", "LBRACK", "SEMI", "RBRACK", "LCURLY", "RCURLY", "DCOLON", "ALLL", "ALLL2", "INT_NUM", "STRING_LITERAL", "CR_ADRESS", "SHARP", "AT", "QUESTION", "BOR", "BAND", "Char", "ESC", "Exponent", "LETTER", "DIGIT", "XDIGIT", "WS" };

  protected FRParser(TokenBuffer paramTokenBuffer, int paramInt)
  {
    super(paramTokenBuffer, paramInt);
    this.tokenNames = _tokenNames;
  }

  public FRParser(TokenBuffer paramTokenBuffer)
  {
    this(paramTokenBuffer, 1);
  }

  protected FRParser(TokenStream paramTokenStream, int paramInt)
  {
    super(paramTokenStream, paramInt);
    this.tokenNames = _tokenNames;
  }

  public FRParser(TokenStream paramTokenStream)
  {
    this(paramTokenStream, 1);
  }

  public FRParser(ParserSharedInputState paramParserSharedInputState)
  {
    super(paramParserSharedInputState, 1);
    this.tokenNames = _tokenNames;
  }

  public final Expression parse()
    throws RecognitionException, TokenStreamException
  {
    ConditionalOrExpression localConditionalOrExpression = conditionOr();
    match(1);
    Expression localExpression = new Expression(localConditionalOrExpression);
    return localExpression;
  }

  protected final ConditionalOrExpression conditionOr()
    throws RecognitionException, TokenStreamException
  {
    ArrayList localArrayList = new ArrayList();
    ConditionalAndExpression localConditionalAndExpression = conditionAnd();
    localArrayList.add(localConditionalAndExpression);
    while (LA(1) == 6)
    {
      match(6);
      localConditionalAndExpression = conditionAnd();
      localArrayList.add(localConditionalAndExpression);
    }
    ConditionalOrExpression localConditionalOrExpression = new ConditionalOrExpression((ConditionalAndExpression[])localArrayList.toArray(new ConditionalAndExpression[localArrayList.size()]));
    return localConditionalOrExpression;
  }

  protected final ConditionalAndExpression conditionAnd()
    throws RecognitionException, TokenStreamException
  {
    ArrayList localArrayList = new ArrayList();
    RelationExpression localRelationExpression = relation();
    localArrayList.add(localRelationExpression);
    while (LA(1) == 7)
    {
      match(7);
      localRelationExpression = relation();
      localArrayList.add(localRelationExpression);
    }
    ConditionalAndExpression localConditionalAndExpression = new ConditionalAndExpression((RelationExpression[])localArrayList.toArray(new RelationExpression[localArrayList.size()]));
    return localConditionalAndExpression;
  }

  protected final RelationExpression relation()
    throws RecognitionException, TokenStreamException
  {
    Token localToken1 = null;
    Token localToken2 = null;
    Token localToken3 = null;
    Token localToken4 = null;
    Token localToken5 = null;
    Token localToken6 = null;
    Token localToken7 = null;
    Token localToken8 = null;
    AddExpression localAddExpression1 = null;
    String str = null;
    AddExpression localAddExpression2 = null;
    localAddExpression1 = add();
    switch (LA(1))
    {
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
      switch (LA(1))
      {
      case 8:
        localToken1 = LT(1);
        match(8);
        str = "=";
        break;
      case 9:
        localToken2 = LT(1);
        match(9);
        str = localToken2.getText();
        break;
      case 10:
        localToken3 = LT(1);
        match(10);
        str = localToken3.getText();
        break;
      case 11:
        localToken4 = LT(1);
        match(11);
        str = localToken4.getText();
        break;
      case 12:
        localToken5 = LT(1);
        match(12);
        str = localToken5.getText();
        break;
      case 13:
        localToken6 = LT(1);
        match(13);
        str = localToken6.getText();
        break;
      case 14:
        localToken7 = LT(1);
        match(14);
        str = localToken7.getText();
        break;
      case 15:
        localToken8 = LT(1);
        match(15);
        str = localToken8.getText();
        break;
      default:
        throw new NoViableAltException(LT(1), getFilename());
      }
      localAddExpression2 = add();
      break;
    case 1:
    case 6:
    case 7:
    case 25:
    case 26:
    case 30:
    case 32:
    case 33:
      break;
    case 2:
    case 3:
    case 4:
    case 5:
    case 16:
    case 17:
    case 18:
    case 19:
    case 20:
    case 21:
    case 22:
    case 23:
    case 24:
    case 27:
    case 28:
    case 29:
    case 31:
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    RelationExpression localRelationExpression = new RelationExpression(localAddExpression1, str, localAddExpression2);
    return localRelationExpression;
  }

  protected final AddExpression add()
    throws RecognitionException, TokenStreamException
  {
    Token localToken1 = null;
    Token localToken2 = null;
    ArrayList localArrayList1 = new ArrayList();
    ArrayList localArrayList2 = new ArrayList();
    MultiExpression localMultiExpression = multi();
    localArrayList1.add(localMultiExpression);
    while ((LA(1) == 16) || (LA(1) == 17))
    {
      switch (LA(1))
      {
      case 16:
        localToken1 = LT(1);
        match(16);
        localArrayList2.add(localToken1.getText());
        break;
      case 17:
        localToken2 = LT(1);
        match(17);
        localArrayList2.add(localToken2.getText());
        break;
      default:
        throw new NoViableAltException(LT(1), getFilename());
      }
      localMultiExpression = multi();
      localArrayList1.add(localMultiExpression);
    }
    AddExpression localAddExpression = new AddExpression((MultiExpression[])localArrayList1.toArray(new MultiExpression[localArrayList1.size()]), (String[])localArrayList2.toArray(new String[localArrayList2.size()]));
    return localAddExpression;
  }

  protected final MultiExpression multi()
    throws RecognitionException, TokenStreamException
  {
    Token localToken1 = null;
    Token localToken2 = null;
    Token localToken3 = null;
    ArrayList localArrayList1 = new ArrayList();
    ArrayList localArrayList2 = new ArrayList();
    PowerExpression localPowerExpression = power();
    localArrayList1.add(localPowerExpression);
    while ((LA(1) >= 18) && (LA(1) <= 20))
    {
      switch (LA(1))
      {
      case 18:
        localToken1 = LT(1);
        match(18);
        localArrayList2.add(localToken1.getText());
        break;
      case 19:
        localToken2 = LT(1);
        match(19);
        localArrayList2.add(localToken2.getText());
        break;
      case 20:
        localToken3 = LT(1);
        match(20);
        localArrayList2.add(localToken3.getText());
        break;
      default:
        throw new NoViableAltException(LT(1), getFilename());
      }
      localPowerExpression = power();
      localArrayList1.add(localPowerExpression);
    }
    MultiExpression localMultiExpression = new MultiExpression((PowerExpression[])localArrayList1.toArray(new PowerExpression[localArrayList1.size()]), (String[])localArrayList2.toArray(new String[localArrayList2.size()]));
    return localMultiExpression;
  }

  protected final PowerExpression power()
    throws RecognitionException, TokenStreamException
  {
    ArrayList localArrayList = new ArrayList();
    UnaryExpression localUnaryExpression = unary();
    localArrayList.add(localUnaryExpression);
    while (LA(1) == 21)
    {
      match(21);
      localUnaryExpression = unary();
      localArrayList.add(localUnaryExpression);
    }
    PowerExpression localPowerExpression = new PowerExpression((UnaryExpression[])localArrayList.toArray(new UnaryExpression[localArrayList.size()]));
    return localPowerExpression;
  }

  protected final UnaryExpression unary()
    throws RecognitionException, TokenStreamException
  {
    Object localObject;
    Token localToken1 = null;
    Token localToken2 = null;
    Token localToken3 = null;
    String str = null;
    switch (LA(1))
    {
    case 22:
      localToken1 = LT(1);
      match(22);
      str = localToken1.getText();
      break;
    case 16:
      localToken2 = LT(1);
      match(16);
      str = localToken2.getText();
      break;
    case 17:
      localToken3 = LT(1);
      match(17);
      str = localToken3.getText();
      break;
    case 5:
    case 23:
    case 24:
    case 28:
    case 36:
    case 37:
    case 38:
    case 39:
    case 40:
      break;
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
    case 18:
    case 19:
    case 20:
    case 21:
    case 25:
    case 26:
    case 27:
    case 29:
    case 30:
    case 31:
    case 32:
    case 33:
    case 34:
    case 35:
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    switch (LA(1))
    {
    case 23:
      localObject = ident_prefix();
      break;
    case 37:
      localObject = str_literal();
      break;
    case 5:
    case 36:
      localObject = num_literal();
      break;
    case 38:
      localObject = columnrow_address();
      break;
    case 39:
      localObject = column_index();
      break;
    case 40:
      localObject = layer_index();
      break;
    case 24:
      localObject = closure();
      break;
    case 28:
      localObject = array();
      break;
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    UnaryExpression localUnaryExpression = new UnaryExpression(str, (Atom)localObject);
    return ((UnaryExpression)localUnaryExpression);
  }

  protected final Atom ident_prefix()
    throws RecognitionException, TokenStreamException
  {
    Atom localAtom;
    Token localToken = null;
    String str = null;
    localToken = LT(1);
    match(23);
    str = localToken.getText();
    switch (LA(1))
    {
    case 4:
    case 24:
      localAtom = ident_fn(str);
      break;
    case 22:
      localAtom = ident_sheet(str);
      break;
    case 1:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
    case 16:
    case 17:
    case 18:
    case 19:
    case 20:
    case 21:
    case 25:
    case 26:
    case 27:
    case 28:
    case 30:
    case 31:
    case 32:
    case 33:
      localAtom = ident_cr(str);
      break;
    case 2:
    case 3:
    case 5:
    case 23:
    case 29:
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    return localAtom;
  }

  protected final StringLiteral str_literal()
    throws RecognitionException, TokenStreamException
  {
    Token localToken = null;
    localToken = LT(1);
    match(37);
    String str = localToken.getText();
    StringLiteral localStringLiteral = new StringLiteral(str.substring(1, str.length() - 1));
    return localStringLiteral;
  }

  protected final NumberLiteral num_literal()
    throws RecognitionException, TokenStreamException
  {
    NumberLiteral localNumberLiteral;
    Token localToken1 = null;
    Token localToken2 = null;
    switch (LA(1))
    {
    case 36:
      localToken1 = LT(1);
      match(36);
      localNumberLiteral = new NumberLiteral(localToken1.getText());
      break;
    case 5:
      localToken2 = LT(1);
      match(5);
      localNumberLiteral = new NumberLiteral(localToken2.getText());
      break;
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    return localNumberLiteral;
  }

  protected final CRAddress columnrow_address()
    throws RecognitionException, TokenStreamException
  {
    Token localToken = null;
    localToken = LT(1);
    match(38);
    CRAddress localCRAddress = new CRAddress(ColumnRow.valueOf(localToken.getText().substring(1)));
    return localCRAddress;
  }

  protected final AtomColumnIndex column_index()
    throws RecognitionException, TokenStreamException
  {
    Token localToken = null;
    match(39);
    localToken = LT(1);
    match(36);
    AtomColumnIndex localAtomColumnIndex = new AtomColumnIndex(Integer.parseInt(localToken.getText()));
    return localAtomColumnIndex;
  }

  protected final AtomLayerIndex layer_index()
    throws RecognitionException, TokenStreamException
  {
    Token localToken = null;
    match(40);
    localToken = LT(1);
    match(36);
    AtomLayerIndex localAtomLayerIndex = new AtomLayerIndex(Integer.parseInt(localToken.getText()));
    return localAtomLayerIndex;
  }

  protected final ClosedExpression closure()
    throws RecognitionException, TokenStreamException
  {
    match(24);
    ConditionalOrExpression localConditionalOrExpression = conditionOr();
    match(26);
    ClosedExpression localClosedExpression = new ClosedExpression(localConditionalOrExpression);
    return localClosedExpression;
  }

  protected final ArrayExpression array()
    throws RecognitionException, TokenStreamException
  {
    ArrayList localArrayList = new ArrayList();
    match(28);
    switch (LA(1))
    {
    case 5:
    case 16:
    case 17:
    case 22:
    case 23:
    case 24:
    case 28:
    case 36:
    case 37:
    case 38:
    case 39:
    case 40:
      ConditionalOrExpression localConditionalOrExpression = conditionOr();
      localArrayList.add(localConditionalOrExpression);
      while (true)
        while (true)
        {
          if (LA(1) != 25)
            break label440;
          match(25);
          localArrayList.add(null);
          switch (LA(1))
          {
          case 5:
          case 16:
          case 17:
          case 22:
          case 23:
          case 24:
          case 28:
          case 36:
          case 37:
          case 38:
          case 39:
          case 40:
            localConditionalOrExpression = conditionOr();
            localArrayList.set(localArrayList.size() - 1, localConditionalOrExpression);
          case 25:
          case 30:
          case 6:
          case 7:
          case 8:
          case 9:
          case 10:
          case 11:
          case 12:
          case 13:
          case 14:
          case 15:
          case 18:
          case 19:
          case 20:
          case 21:
          case 26:
          case 27:
          case 29:
          case 31:
          case 32:
          case 33:
          case 34:
          case 35:
          }
        }
      throw new NoViableAltException(LT(1), getFilename());
    case 30:
      break;
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
    case 18:
    case 19:
    case 20:
    case 21:
    case 25:
    case 26:
    case 27:
    case 29:
    case 31:
    case 32:
    case 33:
    case 34:
    case 35:
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    label440: match(30);
    ArrayExpression localArrayExpression = new ArrayExpression((ConditionalOrExpression[])localArrayList.toArray(new ConditionalOrExpression[localArrayList.size()]));
    return localArrayExpression;
  }

  protected final Atom ident_fn(String paramString)
    throws RecognitionException, TokenStreamException
  {
    label536: Object localObject;
    Token localToken = null;
    String str = null;
    ArrayList localArrayList = null;
    switch (LA(1))
    {
    case 4:
      match(4);
      localToken = LT(1);
      match(23);
      str = localToken.getText();
      break;
    case 24:
      break;
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    match(24);
    localArrayList = new ArrayList();
    switch (LA(1))
    {
    case 5:
    case 16:
    case 17:
    case 22:
    case 23:
    case 24:
    case 28:
    case 36:
    case 37:
    case 38:
    case 39:
    case 40:
      ConditionalOrExpression localConditionalOrExpression = conditionOr();
      localArrayList.add(localConditionalOrExpression);
      while (true)
        while (true)
        {
          if (LA(1) != 25)
            break label536;
          match(25);
          localArrayList.add(null);
          switch (LA(1))
          {
          case 5:
          case 16:
          case 17:
          case 22:
          case 23:
          case 24:
          case 28:
          case 36:
          case 37:
          case 38:
          case 39:
          case 40:
            localConditionalOrExpression = conditionOr();
            localArrayList.set(localArrayList.size() - 1, localConditionalOrExpression);
          case 25:
          case 26:
          case 6:
          case 7:
          case 8:
          case 9:
          case 10:
          case 11:
          case 12:
          case 13:
          case 14:
          case 15:
          case 18:
          case 19:
          case 20:
          case 21:
          case 27:
          case 29:
          case 30:
          case 31:
          case 32:
          case 33:
          case 34:
          case 35:
          }
        }
      throw new NoViableAltException(LT(1), getFilename());
    case 26:
      break;
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
    case 18:
    case 19:
    case 20:
    case 21:
    case 25:
    case 27:
    case 29:
    case 30:
    case 31:
    case 32:
    case 33:
    case 34:
    case 35:
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    match(26);
    ConditionalOrExpression[] arrayOfConditionalOrExpression = (ConditionalOrExpression[])localArrayList.toArray(new ConditionalOrExpression[localArrayList.size()]);
    if (str != null)
      localObject = new DatasetFunctionCall(paramString, str, arrayOfConditionalOrExpression);
    else
      localObject = new FunctionCall(paramString, arrayOfConditionalOrExpression);
    return ((Atom)localObject);
  }

  protected final Atom ident_sheet(String paramString)
    throws RecognitionException, TokenStreamException
  {
    Token localToken = null;
    String str = null;
    match(22);
    localToken = LT(1);
    match(23);
    str = localToken.getText();
    Atom localAtom = ident_cr(str);
    SheetIntervalLiteral localSheetIntervalLiteral = new SheetIntervalLiteral(paramString, localAtom);
    return localSheetIntervalLiteral;
  }

  protected final Atom ident_cr(String paramString)
    throws RecognitionException, TokenStreamException
  {
    Token localToken = null;
    if (!(paramString.matches("^[a-zA-Z]+[1-9]\\d*$")))
      return new Ambiguity(paramString);
    ColumnRow localColumnRow = ColumnRow.valueOf(paramString);
    if ((localColumnRow.getColumn() < 0) || (localColumnRow.getRow() < 0))
      return new Ambiguity(paramString);
    ColumnRowLiteral localColumnRowLiteral1 = null;
    ColumnRowLiteral localColumnRowLiteral2 = null;
    localColumnRowLiteral1 = columnrow_literal(localColumnRow);
    switch (LA(1))
    {
    case 27:
      match(27);
      localToken = LT(1);
      match(23);
      localColumnRow = ColumnRow.valueOf(localToken.getText());
      localColumnRowLiteral2 = columnrow_literal(localColumnRow);
      break;
    case 1:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
    case 16:
    case 17:
    case 18:
    case 19:
    case 20:
    case 21:
    case 25:
    case 26:
    case 30:
    case 32:
    case 33:
      break;
    case 2:
    case 3:
    case 4:
    case 5:
    case 22:
    case 23:
    case 24:
    case 28:
    case 29:
    case 31:
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    ColumnRowRange localColumnRowRange = new ColumnRowRange(localColumnRowLiteral1, localColumnRowLiteral2);
    return localColumnRowRange;
  }

  protected final ColumnRowLiteral columnrow_literal(ColumnRow paramColumnRow)
    throws RecognitionException, TokenStreamException
  {
    ColumnRowLocation localColumnRowLocation1 = null;
    ColumnRowLocation localColumnRowLocation2 = null;
    ConditionalOrExpression localConditionalOrExpression1 = null;
    ConditionalOrExpression localConditionalOrExpression2 = null;
    ConditionalOrExpression localConditionalOrExpression3 = null;
    switch (LA(1))
    {
    case 28:
      match(28);
      switch (LA(1))
      {
      case 23:
      case 34:
      case 35:
        localColumnRowLocation1 = columnrow_location();
        if (localColumnRowLocation1 == ColumnRowLocation.ALL)
          localColumnRowLocation2 = ColumnRowLocation.ALL;
        break;
      case 29:
      case 30:
        break;
      case 24:
      case 25:
      case 26:
      case 27:
      case 28:
      case 31:
      case 32:
      case 33:
      default:
        throw new NoViableAltException(LT(1), getFilename());
      }
      switch (LA(1))
      {
      case 29:
        match(29);
        localColumnRowLocation2 = null;
        switch (LA(1))
        {
        case 23:
        case 34:
        case 35:
          localColumnRowLocation2 = columnrow_location();
          break;
        case 30:
          break;
        default:
          throw new NoViableAltException(LT(1), getFilename());
        }
      case 30:
        break;
      default:
        throw new NoViableAltException(LT(1), getFilename());
      }
      match(30);
      break;
    case 1:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
    case 16:
    case 17:
    case 18:
    case 19:
    case 20:
    case 21:
    case 25:
    case 26:
    case 27:
    case 30:
    case 31:
    case 32:
    case 33:
      break;
    case 2:
    case 3:
    case 4:
    case 5:
    case 22:
    case 23:
    case 24:
    case 29:
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    switch (LA(1))
    {
    case 31:
      match(31);
      switch (LA(1))
      {
      case 5:
      case 16:
      case 17:
      case 22:
      case 23:
      case 24:
      case 28:
      case 36:
      case 37:
      case 38:
      case 39:
      case 40:
        localConditionalOrExpression1 = conditionOr();
        break;
      case 32:
        break;
      case 6:
      case 7:
      case 8:
      case 9:
      case 10:
      case 11:
      case 12:
      case 13:
      case 14:
      case 15:
      case 18:
      case 19:
      case 20:
      case 21:
      case 25:
      case 26:
      case 27:
      case 29:
      case 30:
      case 31:
      case 33:
      case 34:
      case 35:
      default:
        throw new NoViableAltException(LT(1), getFilename());
      }
      match(32);
      switch (LA(1))
      {
      case 28:
        match(28);
        localConditionalOrExpression2 = conditionOr();
        switch (LA(1))
        {
        case 33:
          match(33);
          localConditionalOrExpression3 = conditionOr();
          break;
        case 30:
          break;
        default:
          throw new NoViableAltException(LT(1), getFilename());
        }
        match(30);
        break;
      case 1:
      case 6:
      case 7:
      case 8:
      case 9:
      case 10:
      case 11:
      case 12:
      case 13:
      case 14:
      case 15:
      case 16:
      case 17:
      case 18:
      case 19:
      case 20:
      case 21:
      case 25:
      case 26:
      case 27:
      case 30:
      case 32:
      case 33:
        break;
      case 2:
      case 3:
      case 4:
      case 5:
      case 22:
      case 23:
      case 24:
      case 29:
      case 31:
      default:
        throw new NoViableAltException(LT(1), getFilename());
      }
    case 1:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
    case 16:
    case 17:
    case 18:
    case 19:
    case 20:
    case 21:
    case 25:
    case 26:
    case 27:
    case 30:
    case 32:
    case 33:
      break;
    case 2:
    case 3:
    case 4:
    case 5:
    case 22:
    case 23:
    case 24:
    case 28:
    case 29:
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    ColumnRowLiteral localColumnRowLiteral = new ColumnRowLiteral(paramColumnRow, localColumnRowLocation1, localColumnRowLocation2, localConditionalOrExpression1, localConditionalOrExpression2, localConditionalOrExpression3);
    return localColumnRowLiteral;
  }

  protected final ColumnRowLocation columnrow_location()
    throws RecognitionException, TokenStreamException
  {
    ColumnRowLocation localColumnRowLocation = null;
    ArrayList localArrayList = new ArrayList();
    switch (LA(1))
    {
    case 34:
    case 35:
      switch (LA(1))
      {
      case 34:
        match(34);
        break;
      case 35:
        match(35);
        break;
      default:
        throw new NoViableAltException(LT(1), getFilename());
      }
      localColumnRowLocation = ColumnRowLocation.ALL;
      break;
    case 23:
      LocationDim localLocationDim = location_dim();
      localArrayList.add(localLocationDim);
      while (LA(1) == 25)
      {
        match(25);
        localLocationDim = location_dim();
        localArrayList.add(localLocationDim);
      }
      if (localColumnRowLocation != null)
        break label217;
      localColumnRowLocation = new ColumnRowLocation((LocationDim[])localArrayList.toArray(new LocationDim[localArrayList.size()]));
      break;
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    label217: return localColumnRowLocation;
  }

  protected final LocationDim location_dim()
    throws RecognitionException, TokenStreamException
  {
    Token localToken1 = null;
    Token localToken2 = null;
    ColumnRow localColumnRow = null;
    byte b = 0;
    int i = 0;
    int j = 0;
    localToken1 = LT(1);
    match(23);
    localColumnRow = ColumnRow.valueOf(localToken1.getText());
    switch (LA(1))
    {
    case 27:
      match(27);
      switch (LA(1))
      {
      case 22:
        match(22);
        j = 1;
        break;
      case 16:
      case 17:
      case 36:
        break;
      default:
        throw new NoViableAltException(LT(1), getFilename());
      }
      switch (LA(1))
      {
      case 16:
        match(16);
        b = 1;
        break;
      case 17:
        match(17);
        b = 2;
        break;
      case 36:
        break;
      default:
        throw new NoViableAltException(LT(1), getFilename());
      }
      localToken2 = LT(1);
      match(36);
      i = Integer.parseInt(localToken2.getText());
      break;
    case 25:
    case 29:
    case 30:
      break;
    case 26:
    case 28:
    default:
      throw new NoViableAltException(LT(1), getFilename());
    }
    if (j != 0)
    {
      if (b == 2)
        i = -i;
      b = 0;
    }
    LocationDim localLocationDim = new LocationDim(localColumnRow, b, i);
    return localLocationDim;
  }
}